package com.linzm.server;

import com.linzm.model.Request;
import com.linzm.model.Response;
import lombok.SneakyThrows;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * v2 封装 request response
 *
 * @Date: 2023/11/6 21:37
 * @User linziming
 */
public class BootstrapV2 {
    @SneakyThrows
    public static void main(String[] args) {
        ServerSocket serverSocket = new ServerSocket(8080);
        while (true) {
            Socket socket = serverSocket.accept();
            InputStream inputStream = socket.getInputStream();
            //封装Resuest对象和Response对象
            Request request = new Request(inputStream);
            Response response = new Response(socket.getOutputStream());
            response.outputHtml(request.getUrl());
            socket.close();
        }
    }
}
